﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars.Helpers;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using ThuVienTNN;
using KhoTNN;


namespace KhoTNN
{
    public partial class frmMain : RibbonForm
    {
        public frmMain()
        {
            InitializeComponent();
            InitSkinGallery();
            try
            {
                var chuoiketnoi = string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3}", Properties.Settings.Default.MayChu, Properties.Settings.Default.CSDL, Properties.Settings.Default.TaiKhoan, Properties.Settings.Default.MatKhau);
                Context db = new Context(chuoiketnoi);
                db.ExecuteQuery<string>("select table_name from information_schema.tables");
                
            }
            catch
            {
                
                showfrm.ShowFrm(new frmCauHinhCSDL (),  FormWindowState.Normal  );

            }
            showfrm.ShowFrm(new frmDangNhap(), FormWindowState.Normal);
        }
        void InitSkinGallery()
        {
            SkinHelper.InitSkinGallery(rgbiSkins, true);
        }

                   
        
        //show các tab
        private void bbtnThongTinNguoiDung_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmThongTinNguoiDung());
        }

        private void bbtnQuanLyNguoiDung_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmQuanLyNguoiDung());
        }

        private void bbtnKhachHang_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmKhachHang());
        }

        private void bbtnDonViXuatHang_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmDonViXuatHang());
        }

        private void bbtnHangHoa_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmHangHoa());
        }

        private void bbtnLoaiPhuongTien_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmLoaiPhuongTien());
        }

        private void bbtnXe_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmXe());
        }

        private void bbtnCongNhan_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmCongNhan(),FormWindowState.Normal );
        }

        private void bbtnLaiXe_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmLaiXe());
        }

        private void bbtnKho_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmKho());
        }

        private void bbtnTinhThanh_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmTinhThanh());
        }

        private void bbtnLapPhieuDeNghi_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmLapPhieuDeNghi());
        }

        private void bbtnDanhSachPhieuDeNghi_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmDanhSachPhieuDeNghi());
        }

        private void bbtnDanhSachLenhNhapKho_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmDanhSachLenhNhapKho());
        }

        private void bbtnLapPhieuDeNghiX_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmLapPhieuDeNghiX());
        }

        private void bbtnDanhSachPhieuDeNghiX_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmDanhSachPhieuDeNghiX());
        }

        private void bbtnDanhSachLenhXuatKho_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmDanhSachLenhXuatKho());
        }
        private void bbtnDanhSachHangTon_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmDanhSachHangTon());
        }
        private void bbtnLapPhieuDoiTru_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmLapPhieuDoiTru());
        }

        private void bbtnDanhSachPhieuDoiTru_ItemClick(object sender, ItemClickEventArgs e)
        {
            showTab.OpenTabPage(tabControl, new frmDanhSachPhieuDoiTru());
        }

        private void bbtnThongKeSoLuongDeNghi_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void bbtnThongKeHangTon_ItemClick(object sender, ItemClickEventArgs e)
        {

        }
        //đóng tab
        private void tabControl_CloseButtonClick(object sender, EventArgs e)
        {
            DevExpress.XtraTab.XtraTabControl xtraTabControl = sender as DevExpress.XtraTab.XtraTabControl;
            DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs arg = e as DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs;
            (arg.Page as DevExpress.XtraTab.XtraTabPage).Dispose();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            //showfrm.ShowFrm(new frmDangNhap()  ,FormWindowState.Normal);
        }

        
       
    }
}